﻿#region licence
//  Copyright 2008 Michael Cromwell

//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at

//       http://www.apache.org/licenses/LICENSE-2.0

//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Rhino.DSL;
using System.Configuration;
using NUnit.Framework.SyntaxHelpers;

namespace log4net.altconf.Tests
{
    [TestFixture]
    public class Compilation_specification
    {
        private DslFactory dslFactory;

        [SetUp]
        public void Setup()
        {
            dslFactory = new DslFactory();
            dslFactory.Register<Log4NetDslConfiguration>(new Log4NetDslEngine());
            dslFactory.BaseDirectory = ConfigurationManager.AppSettings["script-base-directory"];
        }

        [TearDown]
        public void Teardown()
        {
            dslFactory = null;
        }
        
        [Test]
        public void Given_a_single_appender_should_compile()
        {
            var config = dslFactory.Create<Log4NetDslConfiguration>("single-appender.boo");
            Assert.That(config, Is.Not.Null);
        }

        [Test]
        public void Given_a_single_appender_and_root_log_should_compile()
        {
            var config = dslFactory.Create<Log4NetDslConfiguration>("appender-and-root-log.boo");
            Assert.That(config, Is.Not.Null);
        }

        [Test]
        public void Given_a_level_added_to_root_should_compile()
        {
            var config = dslFactory.Create<Log4NetDslConfiguration>("level-on-root-log.boo");
            Assert.That(config, Is.Not.Null);
        }

        [Test]
        public void Given_global_options_set_should_compile()
        {
            var config = dslFactory.Create<Log4NetDslConfiguration>("global-options-set.boo");
            Assert.That(config, Is.Not.Null);
        }
    }
}
